<html>
<body>
<h3>Majick properties</h3>
<h4>Wotsit ?</h4>
majick-properties is a library providing interfaces and code for easier manipulation of bean properties.
It allows, through the definition of bean properties this way :
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- =   Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard  markus@jave.de   = -->
<!-- =     Further information: http://www.java2html.de     = -->
<div align="left" class="java">
<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <code>
<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font><font color="#000000">Experience&nbsp;</font><font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;A&nbsp;simple&nbsp;unconstrainted&nbsp;name&nbsp;property&nbsp;should&nbsp;be&nbsp;easily&nbsp;understood&nbsp;by&nbsp;anybody</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;final&nbsp;</b></font><font color="#000000">ComparableProperty&lt;String&gt;&nbsp;nameProperty&nbsp;=&nbsp;PropertyUtils.create</font><font color="#000000">(</font><font color="#000000">String.class,&nbsp;</font><font color="#2a00ff">&#34;name&#34;</font><font color="#000000">,&nbsp;support</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;A&nbsp;constrained&nbsp;double&nbsp;property&nbsp;could&nbsp;allow&nbsp;external&nbsp;code&nbsp;to&nbsp;prevent&nbsp;it&nbsp;from&nbsp;having&nbsp;certain&nbsp;values&nbsp;(see&nbsp;in&nbsp;tests&nbsp;for&nbsp;examples)</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;final&nbsp;</b></font><font color="#000000">ComparableVetoableProperty&lt;Double&gt;&nbsp;valueProperty&nbsp;=&nbsp;PropertyUtils.create</font><font color="#000000">(</font><font color="#000000">Double.class,&nbsp;</font><font color="#2a00ff">&#34;value&#34;</font><font color="#000000">,&nbsp;support,&nbsp;vetoSupport</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#000000">}</font></code>
    
   </td>
  <!-- end source code -->
   </tr>
  <!-- start Java2Html link -->
   <tr>
    <td align="right">
<small>
<a href="http://www.java2html.de" target="_blank">Java2html</a>
</small>
    </td>
   </tr>
  <!-- end Java2Html link -->
</table>
</div>
<!-- =       END of automatically generated HTML code       = -->
<!-- ======================================================== -->

to generate ui components for them this way

<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- =   Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard  markus@jave.de   = -->
<!-- =     Further information: http://www.java2html.de     = -->
<div align="left" class="java">
<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <code>
<font color="#000000">UIProvider&nbsp;provider&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">UIProvider</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#000000">Component&nbsp;component&nbsp;=&nbsp;provider.getEditor</font><font color="#000000">(</font><font color="#000000">experience.getNameProperty</font><font color="#000000">())</font><font color="#000000">;</font></code>
    
   </td>
  <!-- end source code -->
   </tr>
  <!-- start Java2Html link -->
   <tr>
    <td align="right">
<small>
<a href="http://www.java2html.de" target="_blank">Java2html</a>
</small>
    </td>
   </tr>
  <!-- end Java2Html link -->
</table>
</div>
<!-- =       END of automatically generated HTML code       = -->
<!-- ======================================================== -->

<h4>Weaknesses of classical JavaBeans</h4>
For so long ago, I've found rather boring to work with JavaBeans. Especially, one thing made me crazy : each time I want to define a
setter able to send events, I have to rewrite the same code block (which, actually, I put in an Eclipse code template) :<br>
<pre>
public void setValue(Object newValue) {
	if((value==null && newValue!=null) || (value!=null && !value.equals(newValue)) {
		Object old = value;
		value = newValue;
		support.firePropertyChange("value", old, newValue);
	}
}
</pre>
Well, as soon as the bean gets larger than two or three fields, it is a nightmare to write, and an even more nightmarish work to evolve (as an example when setter has to do something besides setting the value (wich, as far as I know, is now firmly discouradged by ayatollahs of separation of concerns, ignoring that, sometimes, member fields of a same bean are tied by buisness rules)).<br>So, as long as I'm concerned, classical Java beans are no more a good conceptual solution.<br>In fact, it goes even farer when considering the uttermost failure that BeanInfo and other constructs are. They're absolutely unusable by hand, making fast bean binding impossible.<br>
<h4>Existing solutions (in other languages)</h4>
Meanwhile, other
platforms have forged solid properties solutions :<br>
<ul>
<li><a href="http://www.c-sharpcorner.com/UploadFile/rajeshvs/PropertiesInCS11122005001040AM/PropertiesInCS.aspx">C# properties</a> are one of them</li>
<li><a href="http://www.ruby-doc.org/docs/UsersGuide/rg/accessors.html">Ruby attr_accessor</a> are, to my mind, the most brilliant solution to this problem</li>
</ul>
<h4>Majick solution ?</h4>
Well, here are some of the inspirations of majick-properties.
<br>And here is the majick-properties mojo : <u>make the use of properties as simple, straightforward, and intuitive as possible</u>.<br>
In a ruby-like fashion, I'll try here to provide tooling and objects allowing easy use of properties in contexts I know.</body>
</html> 